﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Web.Script.Serialization;
using System.Xml.Serialization;
using NewLife;
using NewLife.Data;
using XCode;
using XCode.Cache;
using XCode.Configuration;
using XCode.DataAccessLayer;

namespace Datav.Design.Datas.Pocos;

/// <summary>组件</summary>
[Serializable]
[DataObject]
[Description("组件")]
[BindIndex("IX_p_coms_ProjectId", false, "ProjectId")]
[BindTable("p_coms", Description = "组件", ConnName = "datavdesign", DbType = DatabaseType.None)]
public partial class ProjectComs : IProjectComs, IEntity<IProjectComs>
{
    #region 属性
    private Int64 _Id;
    /// <summary>编号</summary>
    [DisplayName("编号")]
    [Description("编号")]
    [DataObjectField(true, false, false, 0)]
    [BindColumn("Id", "编号", "", DataScale = "time")]
    public Int64 Id { get => _Id; set { if (OnPropertyChanging("Id", value)) { _Id = value; OnPropertyChanged("Id"); } } }

    private Int64 _ParentId;
    /// <summary>父Id</summary>
    [DisplayName("父Id")]
    [Description("父Id")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("ParentId", "父Id", "", DefaultValue = "0")]
    public Int64 ParentId { get => _ParentId; set { if (OnPropertyChanging("ParentId", value)) { _ParentId = value; OnPropertyChanged("ParentId"); } } }

    private String _Paths;
    /// <summary>路径</summary>
    [DisplayName("路径")]
    [Description("路径")]
    [DataObjectField(false, false, true, 50)]
    [BindColumn("Paths", "路径", "")]
    public String Paths { get => _Paths; set { if (OnPropertyChanging("Paths", value)) { _Paths = value; OnPropertyChanged("Paths"); } } }

    private String _Name;
    /// <summary>类型名称</summary>
    [DisplayName("类型名称")]
    [Description("类型名称")]
    [DataObjectField(false, false, true, 50)]
    [BindColumn("Name", "类型名称", "", Master = true)]
    public String Name { get => _Name; set { if (OnPropertyChanging("Name", value)) { _Name = value; OnPropertyChanged("Name"); } } }

    private Int64 _ProjectId;
    /// <summary>案例ID</summary>
    [DisplayName("案例ID")]
    [Description("案例ID")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("ProjectId", "案例ID", "")]
    public Int64 ProjectId { get => _ProjectId; set { if (OnPropertyChanging("ProjectId", value)) { _ProjectId = value; OnPropertyChanged("ProjectId"); } } }

    private String _Attr;
    /// <summary>属性</summary>
    [DisplayName("属性")]
    [Description("属性")]
    [DataObjectField(false, false, true, -1)]
    [BindColumn("Attr", "属性", "")]
    public String Attr { get => _Attr; set { if (OnPropertyChanging("Attr", value)) { _Attr = value; OnPropertyChanged("Attr"); } } }

    private String _Actions;
    /// <summary>东座行动</summary>
    [DisplayName("东座行动")]
    [Description("东座行动")]
    [DataObjectField(false, false, true, -1)]
    [BindColumn("Actions", "东座行动", "")]
    public String Actions { get => _Actions; set { if (OnPropertyChanging("Actions", value)) { _Actions = value; OnPropertyChanged("Actions"); } } }

    private String _Scaling;
    /// <summary>缩放比例</summary>
    [DisplayName("缩放比例")]
    [Description("缩放比例")]
    [DataObjectField(false, false, true, -1)]
    [BindColumn("Scaling", "缩放比例", "")]
    public String Scaling { get => _Scaling; set { if (OnPropertyChanging("Scaling", value)) { _Scaling = value; OnPropertyChanged("Scaling"); } } }

    private String _Alias;
    /// <summary>别名</summary>
    [DisplayName("别名")]
    [Description("别名")]
    [DataObjectField(false, false, true, -1)]
    [BindColumn("Alias", "别名", "")]
    public String Alias { get => _Alias; set { if (OnPropertyChanging("Alias", value)) { _Alias = value; OnPropertyChanged("Alias"); } } }

    private String _ApiData;
    /// <summary>接口数据</summary>
    [DisplayName("接口数据")]
    [Description("接口数据")]
    [DataObjectField(false, false, true, -1)]
    [BindColumn("ApiData", "接口数据", "")]
    public String ApiData { get => _ApiData; set { if (OnPropertyChanging("ApiData", value)) { _ApiData = value; OnPropertyChanged("ApiData"); } } }

    private String _Apis;
    /// <summary>动态APIs</summary>
    [DisplayName("动态APIs")]
    [Description("动态APIs")]
    [DataObjectField(false, false, true, -1)]
    [BindColumn("Apis", "动态APIs", "")]
    public String Apis { get => _Apis; set { if (OnPropertyChanging("Apis", value)) { _Apis = value; OnPropertyChanged("Apis"); } } }

    private String _Config;
    /// <summary>配制</summary>
    [DisplayName("配制")]
    [Description("配制")]
    [DataObjectField(false, false, true, -1)]
    [BindColumn("Config", "配制", "")]
    public String Config { get => _Config; set { if (OnPropertyChanging("Config", value)) { _Config = value; OnPropertyChanged("Config"); } } }

    private String _Events;
    /// <summary>事件</summary>
    [DisplayName("事件")]
    [Description("事件")]
    [DataObjectField(false, false, true, -1)]
    [BindColumn("Events", "事件", "")]
    public String Events { get => _Events; set { if (OnPropertyChanging("Events", value)) { _Events = value; OnPropertyChanged("Events"); } } }

    private String _Icon;
    /// <summary>图标</summary>
    [DisplayName("图标")]
    [Description("图标")]
    [DataObjectField(false, false, true, 1000)]
    [BindColumn("Icon", "图标", "")]
    public String Icon { get => _Icon; set { if (OnPropertyChanging("Icon", value)) { _Icon = value; OnPropertyChanged("Icon"); } } }

    private Int32 _Tag;
    /// <summary>标签</summary>
    [DisplayName("标签")]
    [Description("标签")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("Tag", "标签", "")]
    public Int32 Tag { get => _Tag; set { if (OnPropertyChanging("Tag", value)) { _Tag = value; OnPropertyChanged("Tag"); } } }

    private String _Img;
    /// <summary>背景图</summary>
    [DisplayName("背景图")]
    [Description("背景图")]
    [DataObjectField(false, false, true, 1000)]
    [BindColumn("Img", "背景图", "")]
    public String Img { get => _Img; set { if (OnPropertyChanging("Img", value)) { _Img = value; OnPropertyChanged("Img"); } } }

    private String _Type;
    /// <summary>组件类型</summary>
    [DisplayName("组件类型")]
    [Description("组件类型")]
    [DataObjectField(false, false, true, 100)]
    [BindColumn("Type", "组件类型", "")]
    public String Type { get => _Type; set { if (OnPropertyChanging("Type", value)) { _Type = value; OnPropertyChanged("Type"); } } }

    private Int32 _Sort;
    /// <summary>排序</summary>
    [DisplayName("排序")]
    [Description("排序")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("Sort", "排序", "")]
    public Int32 Sort { get => _Sort; set { if (OnPropertyChanging("Sort", value)) { _Sort = value; OnPropertyChanged("Sort"); } } }

    private Boolean _Selected;
    /// <summary>选中</summary>
    [DisplayName("选中")]
    [Description("选中")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("Selected", "选中", "")]
    public Boolean Selected { get => _Selected; set { if (OnPropertyChanging("Selected", value)) { _Selected = value; OnPropertyChanged("Selected"); } } }

    private Boolean _Locked;
    /// <summary>锁</summary>
    [DisplayName("锁")]
    [Description("锁")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("Locked", "锁", "")]
    public Boolean Locked { get => _Locked; set { if (OnPropertyChanging("Locked", value)) { _Locked = value; OnPropertyChanged("Locked"); } } }

    private Boolean _Hided;
    /// <summary>缩放比例</summary>
    [DisplayName("缩放比例")]
    [Description("缩放比例")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("Hided", "缩放比例", "")]
    public Boolean Hided { get => _Hided; set { if (OnPropertyChanging("Hided", value)) { _Hided = value; OnPropertyChanged("Hided"); } } }

    private Boolean _Hovered;
    /// <summary>Hovered</summary>
    [DisplayName("Hovered")]
    [Description("Hovered")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("Hovered", "Hovered", "")]
    public Boolean Hovered { get => _Hovered; set { if (OnPropertyChanging("Hovered", value)) { _Hovered = value; OnPropertyChanged("Hovered"); } } }

    private Boolean _Renameing;
    /// <summary>名称</summary>
    [DisplayName("名称")]
    [Description("名称")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("Renameing", "名称", "")]
    public Boolean Renameing { get => _Renameing; set { if (OnPropertyChanging("Renameing", value)) { _Renameing = value; OnPropertyChanged("Renameing"); } } }

    private Int64 _TenantId;
    /// <summary>租户id</summary>
    [DisplayName("租户id")]
    [Description("租户id")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("TenantId", "租户id", "")]
    public Int64 TenantId { get => _TenantId; set { if (OnPropertyChanging("TenantId", value)) { _TenantId = value; OnPropertyChanged("TenantId"); } } }

    private Int32 _IsDelete;
    /// <summary>是否删除</summary>
    [DisplayName("是否删除")]
    [Description("是否删除")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("IsDelete", "是否删除", "", DefaultValue = "0")]
    public Int32 IsDelete { get => _IsDelete; set { if (OnPropertyChanging("IsDelete", value)) { _IsDelete = value; OnPropertyChanged("IsDelete"); } } }

    private DateTime _CreateTime;
    /// <summary>创建时间</summary>
    [Category("扩展")]
    [DisplayName("创建时间")]
    [Description("创建时间")]
    [DataObjectField(false, false, true, 0)]
    [BindColumn("CreateTime", "创建时间", "")]
    public DateTime CreateTime { get => _CreateTime; set { if (OnPropertyChanging("CreateTime", value)) { _CreateTime = value; OnPropertyChanged("CreateTime"); } } }

    private Int64 _CreateBy;
    /// <summary>创建人</summary>
    [Category("扩展")]
    [DisplayName("创建人")]
    [Description("创建人")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("CreateBy", "创建人", "")]
    public Int64 CreateBy { get => _CreateBy; set { if (OnPropertyChanging("CreateBy", value)) { _CreateBy = value; OnPropertyChanged("CreateBy"); } } }

    private String _CreateName;
    /// <summary>创建人名称</summary>
    [Category("扩展")]
    [DisplayName("创建人名称")]
    [Description("创建人名称")]
    [DataObjectField(false, false, true, 50)]
    [BindColumn("CreateName", "创建人名称", "")]
    public String CreateName { get => _CreateName; set { if (OnPropertyChanging("CreateName", value)) { _CreateName = value; OnPropertyChanged("CreateName"); } } }

    private DateTime _UpdateTime;
    /// <summary>更新时间</summary>
    [Category("扩展")]
    [DisplayName("更新时间")]
    [Description("更新时间")]
    [DataObjectField(false, false, true, 0)]
    [BindColumn("UpdateTime", "更新时间", "")]
    public DateTime UpdateTime { get => _UpdateTime; set { if (OnPropertyChanging("UpdateTime", value)) { _UpdateTime = value; OnPropertyChanged("UpdateTime"); } } }

    private Int64 _UpdateBy;
    /// <summary>修改建人</summary>
    [DisplayName("修改建人")]
    [Description("修改建人")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("UpdateBy", "修改建人", "")]
    public Int64 UpdateBy { get => _UpdateBy; set { if (OnPropertyChanging("UpdateBy", value)) { _UpdateBy = value; OnPropertyChanged("UpdateBy"); } } }
    #endregion

    #region 拷贝
    /// <summary>拷贝模型对象</summary>
    /// <param name="model">模型</param>
    public void Copy(IProjectComs model)
    {
        Id = model.Id;
        ParentId = model.ParentId;
        Paths = model.Paths;
        Name = model.Name;
        ProjectId = model.ProjectId;
        Attr = model.Attr;
        Actions = model.Actions;
        Scaling = model.Scaling;
        Alias = model.Alias;
        ApiData = model.ApiData;
        Apis = model.Apis;
        Config = model.Config;
        Events = model.Events;
        Icon = model.Icon;
        Tag = model.Tag;
        Img = model.Img;
        Type = model.Type;
        Sort = model.Sort;
        Selected = model.Selected;
        Locked = model.Locked;
        Hided = model.Hided;
        Hovered = model.Hovered;
        Renameing = model.Renameing;
        TenantId = model.TenantId;
        IsDelete = model.IsDelete;
        CreateTime = model.CreateTime;
        CreateBy = model.CreateBy;
        CreateName = model.CreateName;
        UpdateTime = model.UpdateTime;
        UpdateBy = model.UpdateBy;
    }
    #endregion

    #region 获取/设置 字段值
    /// <summary>获取/设置 字段值</summary>
    /// <param name="name">字段名</param>
    /// <returns></returns>
    public override Object this[String name]
    {
        get => name switch
        {
            "Id" => _Id,
            "ParentId" => _ParentId,
            "Paths" => _Paths,
            "Name" => _Name,
            "ProjectId" => _ProjectId,
            "Attr" => _Attr,
            "Actions" => _Actions,
            "Scaling" => _Scaling,
            "Alias" => _Alias,
            "ApiData" => _ApiData,
            "Apis" => _Apis,
            "Config" => _Config,
            "Events" => _Events,
            "Icon" => _Icon,
            "Tag" => _Tag,
            "Img" => _Img,
            "Type" => _Type,
            "Sort" => _Sort,
            "Selected" => _Selected,
            "Locked" => _Locked,
            "Hided" => _Hided,
            "Hovered" => _Hovered,
            "Renameing" => _Renameing,
            "TenantId" => _TenantId,
            "IsDelete" => _IsDelete,
            "CreateTime" => _CreateTime,
            "CreateBy" => _CreateBy,
            "CreateName" => _CreateName,
            "UpdateTime" => _UpdateTime,
            "UpdateBy" => _UpdateBy,
            _ => base[name]
        };
        set
        {
            switch (name)
            {
                case "Id": _Id = value.ToLong(); break;
                case "ParentId": _ParentId = value.ToLong(); break;
                case "Paths": _Paths = Convert.ToString(value); break;
                case "Name": _Name = Convert.ToString(value); break;
                case "ProjectId": _ProjectId = value.ToLong(); break;
                case "Attr": _Attr = Convert.ToString(value); break;
                case "Actions": _Actions = Convert.ToString(value); break;
                case "Scaling": _Scaling = Convert.ToString(value); break;
                case "Alias": _Alias = Convert.ToString(value); break;
                case "ApiData": _ApiData = Convert.ToString(value); break;
                case "Apis": _Apis = Convert.ToString(value); break;
                case "Config": _Config = Convert.ToString(value); break;
                case "Events": _Events = Convert.ToString(value); break;
                case "Icon": _Icon = Convert.ToString(value); break;
                case "Tag": _Tag = value.ToInt(); break;
                case "Img": _Img = Convert.ToString(value); break;
                case "Type": _Type = Convert.ToString(value); break;
                case "Sort": _Sort = value.ToInt(); break;
                case "Selected": _Selected = value.ToBoolean(); break;
                case "Locked": _Locked = value.ToBoolean(); break;
                case "Hided": _Hided = value.ToBoolean(); break;
                case "Hovered": _Hovered = value.ToBoolean(); break;
                case "Renameing": _Renameing = value.ToBoolean(); break;
                case "TenantId": _TenantId = value.ToLong(); break;
                case "IsDelete": _IsDelete = value.ToInt(); break;
                case "CreateTime": _CreateTime = value.ToDateTime(); break;
                case "CreateBy": _CreateBy = value.ToLong(); break;
                case "CreateName": _CreateName = Convert.ToString(value); break;
                case "UpdateTime": _UpdateTime = value.ToDateTime(); break;
                case "UpdateBy": _UpdateBy = value.ToLong(); break;
                default: base[name] = value; break;
            }
        }
    }
    #endregion

    #region 关联映射
    #endregion

    #region 扩展查询
    /// <summary>根据案例ID查找</summary>
    /// <param name="projectId">案例ID</param>
    /// <returns>实体列表</returns>
    public static IList<ProjectComs> FindAllByProjectId(Int64 projectId)
    {
        if (projectId < 0) return [];

        return FindAll(_.ProjectId == projectId);
    }
    #endregion

    #region 数据清理
    /// <summary>清理指定时间段内的数据</summary>
    /// <param name="start">开始时间。未指定时清理小于指定时间的所有数据</param>
    /// <param name="end">结束时间</param>
    /// <returns>清理行数</returns>
    public static Int32 DeleteWith(DateTime start, DateTime end)
    {
        return Delete(_.Id.Between(start, end, Meta.Factory.Snow));
    }
    #endregion

    #region 字段名
    /// <summary>取得组件字段信息的快捷方式</summary>
    public partial class _
    {
        /// <summary>编号</summary>
        public static readonly Field Id = FindByName("Id");

        /// <summary>父Id</summary>
        public static readonly Field ParentId = FindByName("ParentId");

        /// <summary>路径</summary>
        public static readonly Field Paths = FindByName("Paths");

        /// <summary>类型名称</summary>
        public static readonly Field Name = FindByName("Name");

        /// <summary>案例ID</summary>
        public static readonly Field ProjectId = FindByName("ProjectId");

        /// <summary>属性</summary>
        public static readonly Field Attr = FindByName("Attr");

        /// <summary>东座行动</summary>
        public static readonly Field Actions = FindByName("Actions");

        /// <summary>缩放比例</summary>
        public static readonly Field Scaling = FindByName("Scaling");

        /// <summary>别名</summary>
        public static readonly Field Alias = FindByName("Alias");

        /// <summary>接口数据</summary>
        public static readonly Field ApiData = FindByName("ApiData");

        /// <summary>动态APIs</summary>
        public static readonly Field Apis = FindByName("Apis");

        /// <summary>配制</summary>
        public static readonly Field Config = FindByName("Config");

        /// <summary>事件</summary>
        public static readonly Field Events = FindByName("Events");

        /// <summary>图标</summary>
        public static readonly Field Icon = FindByName("Icon");

        /// <summary>标签</summary>
        public static readonly Field Tag = FindByName("Tag");

        /// <summary>背景图</summary>
        public static readonly Field Img = FindByName("Img");

        /// <summary>组件类型</summary>
        public static readonly Field Type = FindByName("Type");

        /// <summary>排序</summary>
        public static readonly Field Sort = FindByName("Sort");

        /// <summary>选中</summary>
        public static readonly Field Selected = FindByName("Selected");

        /// <summary>锁</summary>
        public static readonly Field Locked = FindByName("Locked");

        /// <summary>缩放比例</summary>
        public static readonly Field Hided = FindByName("Hided");

        /// <summary>Hovered</summary>
        public static readonly Field Hovered = FindByName("Hovered");

        /// <summary>名称</summary>
        public static readonly Field Renameing = FindByName("Renameing");

        /// <summary>租户id</summary>
        public static readonly Field TenantId = FindByName("TenantId");

        /// <summary>是否删除</summary>
        public static readonly Field IsDelete = FindByName("IsDelete");

        /// <summary>创建时间</summary>
        public static readonly Field CreateTime = FindByName("CreateTime");

        /// <summary>创建人</summary>
        public static readonly Field CreateBy = FindByName("CreateBy");

        /// <summary>创建人名称</summary>
        public static readonly Field CreateName = FindByName("CreateName");

        /// <summary>更新时间</summary>
        public static readonly Field UpdateTime = FindByName("UpdateTime");

        /// <summary>修改建人</summary>
        public static readonly Field UpdateBy = FindByName("UpdateBy");

        static Field FindByName(String name) => Meta.Table.FindByName(name);
    }

    /// <summary>取得组件字段名称的快捷方式</summary>
    public partial class __
    {
        /// <summary>编号</summary>
        public const String Id = "Id";

        /// <summary>父Id</summary>
        public const String ParentId = "ParentId";

        /// <summary>路径</summary>
        public const String Paths = "Paths";

        /// <summary>类型名称</summary>
        public const String Name = "Name";

        /// <summary>案例ID</summary>
        public const String ProjectId = "ProjectId";

        /// <summary>属性</summary>
        public const String Attr = "Attr";

        /// <summary>东座行动</summary>
        public const String Actions = "Actions";

        /// <summary>缩放比例</summary>
        public const String Scaling = "Scaling";

        /// <summary>别名</summary>
        public const String Alias = "Alias";

        /// <summary>接口数据</summary>
        public const String ApiData = "ApiData";

        /// <summary>动态APIs</summary>
        public const String Apis = "Apis";

        /// <summary>配制</summary>
        public const String Config = "Config";

        /// <summary>事件</summary>
        public const String Events = "Events";

        /// <summary>图标</summary>
        public const String Icon = "Icon";

        /// <summary>标签</summary>
        public const String Tag = "Tag";

        /// <summary>背景图</summary>
        public const String Img = "Img";

        /// <summary>组件类型</summary>
        public const String Type = "Type";

        /// <summary>排序</summary>
        public const String Sort = "Sort";

        /// <summary>选中</summary>
        public const String Selected = "Selected";

        /// <summary>锁</summary>
        public const String Locked = "Locked";

        /// <summary>缩放比例</summary>
        public const String Hided = "Hided";

        /// <summary>Hovered</summary>
        public const String Hovered = "Hovered";

        /// <summary>名称</summary>
        public const String Renameing = "Renameing";

        /// <summary>租户id</summary>
        public const String TenantId = "TenantId";

        /// <summary>是否删除</summary>
        public const String IsDelete = "IsDelete";

        /// <summary>创建时间</summary>
        public const String CreateTime = "CreateTime";

        /// <summary>创建人</summary>
        public const String CreateBy = "CreateBy";

        /// <summary>创建人名称</summary>
        public const String CreateName = "CreateName";

        /// <summary>更新时间</summary>
        public const String UpdateTime = "UpdateTime";

        /// <summary>修改建人</summary>
        public const String UpdateBy = "UpdateBy";
    }
    #endregion
}
